package demo07_AuxiliaryClass;

import java.util.concurrent.CountDownLatch;

/**
 * @author kunkun
 * @className Test01_CountDownLatch
 * @Description 测试减法计数器
 * @date 2025/3/6 10:48
 */
public class Test01_CountDownLatch {

    public static void main(String[] args) throws InterruptedException {

        //1. 新建减法计数器
        CountDownLatch count = new CountDownLatch(5);
        //2. 执行线程任务
        for (int i = 0; i < 5; i++) {
            new Thread(()->{
                System.out.println("线程"+Thread.currentThread().getName()+"go out");
                count.countDown();
            },"Thread"+(i+1)).start();
        }
        //3. 等待所有线程执行完毕
        count.await();
        System.out.println("所有线程执行完毕");


    }

}
